<template>
	<el-dialog title="内网权限设置" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" ref="dialogForm" label-width="80px" label-position="left">
			<el-form-item label="目录名称" prop="titleName">{{form.titleName}}</el-form-item>
			<el-form-item label="访问人员" prop="inUserRole">
				<select-user-dialog v-model:accountId="form.inUserRole" :mode="true"/>
			</el-form-item>
			<el-form-item label="访问部门" prop="inDeptRole">
				<select-dept-dialog v-model:deptId="form.inDeptRole" :mode="true"/>
			</el-form-item>
			<el-form-item label="访问职务" prop="inLevelRole">
				<select-user-level-dialog v-model:levelId="form.inLevelRole" :mode="true"/>
			</el-form-item>
			<el-form-item label="排除人员" prop="excInUser">
				<select-user-dialog v-model:accountId="form.excInUser" :mode="true"/>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false" >取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import selectDeptDialog from "@/views/module/selectDeptDialog";
import selectUserLevelDialog from "@/views/module/selectUserLevelDialog";
export default {
	emits: ['success', 'closed'],
	components: {
		selectUserLevelDialog,
		selectUserDialog,
		selectDeptDialog,
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			form: {
				itemId:"",
				titleName: "",
				inUserRole:'',
				inDeptRole:'',
				inLevelRole:'',
				excInUser:'',
			},
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(){
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit(){
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.file.fileMap.updateFileMapItem.post(this.form);
					this.isSaveing = false;
					if(res.code == 200){
						this.$emit('success')
						this.visible = false;
						this.$message.success("操作成功")
					}else{
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		//表单注入数据
		setData(data){
			this.form.itemId = data.itemId
			this.form.titleName = data.titleName
			this.form.inUserRole = data.inUserRole
			this.form.inDeptRole = data.inDeptRole
			this.form.inLevelRole = data.inLevelRole
			this.form.excInUser = data.excInUser
		}
	}
}
</script>

<style>
</style>
